package com.base.mapper;

import com.base.entity.Room;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2024-11-29
 */
@Mapper
public interface RoomMapper extends BaseMapper<Room> {

    @Select({
            "<script>",
            "SELECT * FROM room WHERE 1=1",
            "<if test='type != null and type != \"\"'>",
            " AND type like CONCAT('%', #{type}, '%')",
            "</if>",
            "<if test='location != null and location != \"\"'>",
            "AND location = #{location}",
            "</if>",
            "<if test='price != null'>",
            "AND price = #{price}",
            "</if>",
            "<if test='isFree != null'>",
            "AND is_free = #{isFree}",
            "</if>",
            "</script>"
    })
    List<Room> search(Room room);

}
